home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mm / mm-0.90 / chartype.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-18  |  3.2 KB  |  68 lines

  1. /*
  2.  * Copyright (c) 1986, 1990 by The Trustees of Columbia University in
  3.  * the City of New York.  Permission is granted to any individual or
  4.  * institution to use, copy, or redistribute this software so long as it
  5.  * is not sold for profit, provided this copyright notice is retained.
  6.  */
  7.  
  8. #ifdef RCSID
  9. #ifndef lint
  10. static char *chart_rcsid = "$Header: /f/src2/encore.bin/cucca/mm/tarring-it-up/RCS/chartype.h,v 2.1 90/10/04 18:23:38 melissa Exp $";
  11. #endif
  12. #endif /* RCSID */
  13.  
  14. #define C_UPPER        0001        /* uppercase */
  15. #define C_LOWER        0002        /* lowercase */
  16. #define C_DIGIT        0004        /* 0-9 */
  17. #define C_SPACE        0010        /* space or tab */
  18. #define    C_PUNCT        0020        /* some punctuation */
  19. #define C_PUNC2        0040        /* RFC822 special punctuation */
  20. #define C_EOL        0100        /* return or newline */
  21. #define C_UNUSED    0200        /* unused */
  22. #define C_PRINT        (c_upper|c_lower|c_digit|c_punct|c_punc2)
  23.  
  24. extern unsigned char chartype[256];    /* length == 2^(bits/char) */
  25.  
  26. #define isalpha(x) (chartype[(unsigned char) (x)] & (C_UPPER|C_LOWER))
  27. #define isupper(x) (chartype[(unsigned char) (x)] & (C_UPPER))
  28. #define islower(x) (chartype[(unsigned char) (x)] & (C_LOWER))
  29. #define isdigit(x) (chartype[(unsigned char) (x)] & (C_DIGIT))
  30. #define isalnum(x) (chartype[(unsigned char) (x)] & (C_DIGIT|C_UPPER|C_LOWER))
  31. #define isspace(x) (chartype[(unsigned char) (x)] & (C_SPACE|C_EOL))
  32. #define ispunct(x) (chartype[(unsigned char) (x)] & (C_PUNCT|C_PUNC2))
  33. #define isgraph(x) (chartype[(unsigned char) (x)] & \
  34.             (C_UPPER|C_LOWER|C_DIGIT|C_PUNCT|C_PUNC2))
  35. #define isprint(x) (((unsigned) ((x) - 040)) < 0137)
  36. #define iscntrl(x) (chartype[(unsigned char) (x)]==0)
  37. #define isascii(x) (((unsigned) (x)) <= 0177)
  38. #define isblank(x) (chartype[(unsigned char) (x)] & (C_SPACE))
  39. #define isspecial(x) (chartype[(unsigned char) (x)] & (C_PUNC2))
  40. #define isatom(x)  (chartype[(unsigned char) (x)] & \
  41.             (C_DIGIT|C_UPPER|C_LOWER|C_PUNCT))
  42. #define iseol(x)   (chartype[(unsigned char) (x)] & (C_EOL))
  43.  
  44. #define toupper(c) ((c) <= 'z' && (c) >= 'a' ? (c) - 'a' + 'A' : (c))
  45. #define tolower(c) ((c) <= 'Z' && (c) >= 'A' ? (c) - 'A' + 'a' : (c))
  46.  
  47. #ifdef _CHARTYPE_ARRAY_
  48. unsigned char chartype[256] = {
  49.     0, 0, 0, 0, 0, 0, 0, 0,
  50.     0, C_SPACE, C_EOL, 0, C_EOL, C_EOL, 0, 0,
  51.     0, 0, 0, 0, 0, 0, 0, 0,
  52.     0, 0, 0, 0, 0, 0, 0, 0,
  53.     C_SPACE, C_PUNCT, C_PUNC2, C_PUNCT, C_PUNCT, C_PUNCT, C_PUNCT, C_PUNCT,
  54.     C_PUNC2, C_PUNC2, C_PUNCT, C_PUNCT, C_PUNC2, C_PUNCT, C_PUNC2, C_PUNCT,
  55.     C_DIGIT, C_DIGIT, C_DIGIT, C_DIGIT, C_DIGIT, C_DIGIT, C_DIGIT, C_DIGIT,
  56.     C_DIGIT, C_DIGIT, C_PUNC2, C_PUNC2, C_PUNC2, C_PUNCT, C_PUNC2, C_PUNCT,
  57.     C_PUNC2, C_UPPER, C_UPPER, C_UPPER, C_UPPER, C_UPPER, C_UPPER, C_UPPER,
  58.     C_UPPER, C_UPPER, C_UPPER, C_UPPER, C_UPPER, C_UPPER, C_UPPER, C_UPPER,
  59.     C_UPPER, C_UPPER, C_UPPER, C_UPPER, C_UPPER, C_UPPER, C_UPPER, C_UPPER,
  60.     C_UPPER, C_UPPER, C_UPPER, C_PUNC2, C_PUNC2, C_PUNC2, C_PUNCT, C_PUNCT,
  61.     C_PUNCT, C_LOWER, C_LOWER, C_LOWER, C_LOWER, C_LOWER, C_LOWER, C_LOWER,
  62.     C_LOWER, C_LOWER, C_LOWER, C_LOWER, C_LOWER, C_LOWER, C_LOWER, C_LOWER,
  63.     C_LOWER, C_LOWER, C_LOWER, C_LOWER, C_LOWER, C_LOWER, C_LOWER, C_LOWER,
  64.     C_LOWER, C_LOWER, C_LOWER, C_PUNCT, C_PUNCT, C_PUNCT, C_PUNCT, 0
  65. };
  66. #endif /* _CHARTYPE_ARRAY */
  67.  
  68.